package com.googlecode.monitoring.model;

/**
 * Date: Jun 7, 2010
 * Time: 5:38:09 PM
 */
public enum State {
	CHECKED("checked"),
	EMAIL_SENT("email_sent"),
	NEW("new");

	private String name;

	State(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public static State buildFromString(String str) {
		for (State state : State.values()) {
			if (str.equalsIgnoreCase(state.getName())) {
				return state;
			}
		}
		throw new IllegalArgumentException("Invalid State value");
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append("State");
		sb.append("{name='").append(name).append('\'');
		sb.append('}');
		return sb.toString();
	}

}
